package cc.linker.steplink.crm.dao;

import cc.linker.steplink.crm.domain.BindCustomerInfoPo;
import cc.linker.steplink.crm.domain.Customer;
import cc.linker.steplink.crm.domain.Fans;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public interface CustomerDao {
    int deleteByPrimaryKey(String customerId);

    int insert(Customer record);

    int insertSelective(Customer record);

    Customer selectByPrimaryKey(String customerId);

    int updateByPrimaryKeySelective(Customer record);

    int updateByPrimaryKey(Customer record);

    List<Map<String,Object>> getCustomerPageList(Map map);

    List<Map<String, Object>> listCustomer(Map map);

    Map<String,Object> getCustomerById(String id);

    Map<String, Object> getCustomer(String id);

    int insertCustomer(Customer customer);

    Map<String, String> getData(String id);

    List<Map<String, String>> getLabel(Map<String, Object> map);

    void updateState(String id);

    int getCustomerScore(String customerId);

    int setCustomerScore(Map map);

    String selectCustomerIdByOpenIdAndToken(@Param("openId") String openId, @Param("token") String token);

    Map<String, Object> getIdentificationByCustomerId(String customerId);

    Map<String, Object> getCustomerByTokenOpenid(Map<String, String> map);

    int getCustomerCountByPidAndId(@Param("customerId") String customerId, @Param("pid") String pid);

    void saveCustomerParent(Map<String, String> map);

    String getPidByCid(String customerId);

    void insertMapSelective(Map<String, Object> map);

    String selectCustomerIdByGlobalOpenIdAndToken(@Param("globalOpenId") String wxGlobalOpenid, @Param("token") String wxToken);

    String getTotalPayByCid(String id);

    List<Map<String, Object>> getRobotUser(@Param("orgIds") String orgIds, @Param("limitNum") int limitNum);

    List<Map<String, Object>> getRobotUserMarket(@Param("orgIds") String orgIds, @Param("limitNum") int limitNum);

    String getLabelsByOpenidAndToken(@Param("openid") String openid, @Param("token") String token);

    Integer getCustomerCountByOrgId(String orgId);

    void updateRobotActive(@Param("customerId") String customerId, @Param("type") String type);

    void insertCustomerByFans(Fans fans);

    List<Map<String, Object>> getAllCustomerHavingOpenidAndToken();

    List<Map<String, Object>> getAllCustomerHavingOpenidAndTokenOne();

    void updateSubscribeByCustomerId(Map<String, Object> customer);

    Integer getCustomerSubscribeByCustomerId(String customerId);

    String getSalerPhoneNumberByCid(String customerId);

    String getLabelIdsBySalerId(String customerId);

    Map<String, Object> getListCustomerByCid(@Param("id") String id, @Param("orgId") String orgId);

    Map<String, Object> getOrgFunctionOrgId(String orgId);

    List<String> listCustomerByGroupId(String groupId);

    Integer customerClassify(@Param("orgId") String orgId, @Param("o") String o);

    Integer getPhoneNumBySuffix(String suffix);

    void addPhoneNumBySuffix(String suffix);

    void insertAppCustomer(Map map);

    void updateAppCustomer(Map map);

    void updateAppCustomerByPhone(Map map);

    /*
     * 修改用户的创作奖励
     * customerId：用户ID
     * liveAccount:直播账号
     * */
    Integer updateLiveAccountByCustomerId(@Param("customerId") String customerId,
                                          @Param("liveAccount") String liveAccount);

    /*
     * 判断该直播账号是否有其他用户已经绑定
     * */
    Integer isExitLiveAccountCustomer(@Param("liveAccount") String liveAccount,@Param("orgId") String orgId);

    /*
     * 修改用户的创作奖励
     * customerId：用户ID
     * marketingAccount:融媒号账号
     * */
    Integer updateMarketingAccountByCustomerId(@Param("customerId") String customerId,
                                               @Param("marketingAccount") String marketingAccount);

    /*
     * 判断该直播账号是否有其他用户已经绑定
     * */
    Integer isExitMarketingAccountCustomer(@Param("marketingAccount") String marketingAccount,@Param("orgId") String orgId);

    //通过融媒号ID获取用户ID
    String getCustomerIdByMarketing(@Param("marketingAccount") String marketingAccount);

    Integer getIsVip(@Param("customerId") String customerId);

    Integer getIsVipByApp(@Param("customerId") String customerId);

    int getCustomerIntegral(@Param("customerId") String customerId);

    Integer getIsVipLevel(@Param("customerGrowthScore") int customerGrowthScore,@Param("orgId") String orgId);

    void updateMapSelective(Map<String, Object> map);

    String getUserCount(Map<String, Object> map);

    Map getOldCustomer(Map<String, Object> map);

    String getOldCustomerSource(Map<String, Object> map);

    void insertCustomerSource(Map customerOld);

    Map getCustomerByMap(Map<String, Object> params);

    void updateCustomerSourceUserId(Map customer);

    int saveCustomerInfo(Map<String, Object> customerData);

    int saveCustomer(Map<String, Object> customerData);

    String getLabelId(@Param("labelName")String labelName, @Param("orgId")String orgId, @Param("customerId")String customerId);

    int addCustomerLabel(@Param("labelId")String labelId, @Param("customerId")String customerId);

    void addBatchLog(Map<String, Object> customerData);

    void addBatch(Map<String, Object> batch);

    void saveBatch(Map<String, Object> batch);

    void saveBatchLog(Map<String, Object> batch);

    List<Map<String, Object>> getBatchList(Map<String, Object> map);

    List<Map<String, Object>> getBatchLogList(Map<String, Object> map);

    Map<String, Object> getBatchInfo(Integer batchId);

    Integer getCustomerCountById(Map<String, Object> map);

    /**
    * @Description：获取机构下openID是否存在用户
    * @DateTime：2021/5/12 19:19
    * @Params：
    * @Return：
    */
    Integer getOrgCustomerCountByOpenId(@Param("orgId")String orgId,@Param("openId") String openId);

    void insertBlue(Map<String, Object> map);

    void insertBlueInfo(Map<String, Object> map);

    void updateBlue(Map<String, Object> map);

    void updateBlueInfo(Map<String, Object> map);

    void bindCustomerPhone(@Param("customerId")String customerId,@Param("phone") String phone);

    Map crmCustomerInfoByPhone(@Param("customerPhone") String customerPhone,@Param("orgId") String orgId);

    Map getOrgCustomerInfoByPhone(@Param("customerPhone") String customerPhone,@Param("orgId") String orgId);

    void updateOpenId(Map<String, Object> map);

    void updateBlueWxInfo(Map<String, Object> map);

    Map<String, Object> crmCustomerInfoByCustomerId(@Param("customerId") String customerId);

    Map<String,Object> getOrgCustomerInfoByOpenId(@Param("orgId") String orgId,@Param("openId") String openId);

     BindCustomerInfoPo getOrgCustomerInfoByCustomerId(@Param("customerId") String customerId);

    void saveCouponGiveLog(Map<String, Object> params);

    void saveTrack(Map<String, Object> param);
    /**
     *  通过customerId 和orgId 查询email
     * @param customerIdList
     * @param orgId
     * @return
     */
    List<String> getEmailsByCustomerIds(@Param("customerIdList") List<String> customerIdList, @Param("orgId") String orgId);
}